package com.tj.jinzao.activity;

import android.content.Intent;
import android.text.InputFilter;
import android.text.TextUtils;
import android.widget.EditText;

import com.tj.jinzao.R;
import com.tj.jinzao.base.BaseActivity;
import com.tj.jinzao.utils.ToastUtils;
import com.tj.jinzao.utils.Utils;
import com.tj.jinzao.widgets.MaxTextLengthFilter;


import butterknife.BindView;

/**
 * 发布话题1
 * Created by wjy on 2019/1/12.
 */
public class PublicTopic1Activity extends BaseActivity {

    @BindView(R.id.et_content)
    EditText mContentView;

    @Override
    public int getLayoutResource() {
        return R.layout.activity_public_topic_1;
    }

    @Override
    protected int getLeftButtonResId() {
        return R.mipmap.ic_back;
    }

    @Override
    protected CharSequence getRightButtonText() {
        return "下一步";
    }

    @Override
    protected void setupView() {
        super.setupView();
        mContentView.setFilters(new InputFilter[]{new MaxTextLengthFilter(12,this,"话题标题限12字以内")});

    }

    @Override
    protected void clickRightButton() {
        if (checkResource()) {
            Utils.hideSoftInput(this, getWindow().getDecorView());
            startActivity(new Intent(this, PublicTopic2Activity.class)
                    .putExtra("title", mContentView.getText().toString().trim()));
            finish();
        }
    }

    private boolean checkResource() {
        String content = mContentView.getText().toString().trim();
        if (TextUtils.isEmpty(content)) {
            ToastUtils.showToast(this, "请输入标题");
            return false;
        }
        return true;
    }

}